package Ontology;

import dbcontext.AssociativeTable;

/**
 * 
 * @author michael
 * The class presets a structure containing associative relation
 *
 */
public class WDAssoc
{
    private int iClass1ID;			//	Identifier of attribute
    private int iClass2ID;			//	Identifier of attribute
    private boolean bIsMarked;		//	Is marked?
    private boolean bIsInherited;	//	Is inherited?
    private int iFatherClassID;		//	Class ID the attribute inherited from
    private int iIDFromDB;
    private int iInternalID;
    private boolean bDelIt;			//	Special field for inherited relations preparation. to support bi-derectional inheritance some associative constraints have to be added twice.
    private boolean bLeftRight;		//	Relation from left to the right
    
    
    /**
     * @deprecated replaced by Classes with sStemClassName		2007-01-25
     */
    public WDAssoc( int iiClass1ID, int iiClass2ID, boolean ibIsInherited, int iiFatherClassID, int iiIDFromDB )
    {
    	iClass1ID = iiClass1ID;
    	iClass2ID = iiClass2ID;
    	bIsInherited = ibIsInherited;
    	iFatherClassID = iiFatherClassID;
    	iIDFromDB = iiIDFromDB;
    }

    public WDAssoc( int iiClass1ID, int iiClass2ID, boolean ibIsInherited, int iiFatherClassID, int iiIDFromDB, int iiInternalID )	//	, boolean ibLeftRight
    {
    	iClass1ID = iiClass1ID;
    	iClass2ID = iiClass2ID;
    	bIsInherited = ibIsInherited;
    	iFatherClassID = iiFatherClassID;
    	iIDFromDB = iiIDFromDB;
    	iInternalID = iiInternalID;
    	bDelIt = false;
    	bLeftRight = true;
    }

    public String toString() 
    {
        return "Class1ID: " + iClass1ID + "; Class2ID: " + iClass2ID + "; Is inherited: " + bIsInherited + "; Father class ID: " + iFatherClassID;
    }
    public String toFileWithTab() 
    {
        return "" + iClass1ID + "\t" 
        	+ iClass2ID + "\t"
        	+ ( bIsInherited ? "T" : "F" )
        	+ ( bDelIt ? "T" : "F" )
        	+ ( bLeftRight ? "T" : "F" )
        	;
    }
    /** Stores data to the table 'acon' */
    public void toDatabase(java.sql.Connection conn)
    {
        AssociativeTable.insert(conn, iClass1ID, iClass2ID);
    }
    
    public int getClass1ID() 
    {
        return iClass1ID;
    }
    public int getClass2ID() 
    {
        return iClass2ID;
    }
    public boolean getIsInherited() 
    {
        return bIsInherited;
    }
    public boolean getIsMarked() 
    {
        return bIsMarked;
    }
    public int getFatherClassID() 
    {
        return iFatherClassID;
    }
    public int getIDFromDB() 
    {
        return iIDFromDB;
    }
    public int getInternalID() 
    {
        return iInternalID;
    }
    public boolean getDelIt() 
    {
        return bDelIt;
    }
    public boolean getLeftRight() 
    {
        return bLeftRight;
    }
    
    public void setIsMarked( boolean ibIsMarked ) 
    {
        bIsMarked = ibIsMarked;
        return;
    }
    public void setInheritedClass( int iiFatherClassID ) 
    {
    	iFatherClassID = iiFatherClassID;
    	bIsInherited = true;
        return;
    }
    public void setIsNotInherited( ) 
    {
    	iFatherClassID = iClass1ID;
    	bIsInherited = false;
        return;
    }
    public void setDelIt( boolean ibDelIt ) 
    {
    	bDelIt = ibDelIt;
        return;
    }
    public void setLeftRight( boolean ibLeftRight ) 
    {
    	bLeftRight = ibLeftRight;
        return;
    }
}